using System;
using System.Collections.Generic;

namespace TestCases.CompareAssert.Matchers
{
    public class PredicateEqualityComparer<T>: IEqualityComparer<Predicate<T>>
    {

        private static readonly PredicateEqualityComparer<T> _instance = new PredicateEqualityComparer<T>();

// Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
// ReSharper disable EmptyConstructor
        static PredicateEqualityComparer()
// ReSharper restore EmptyConstructor
        {
        }

        private PredicateEqualityComparer()
        {
        }

        public static PredicateEqualityComparer<T> Instance
        {
            get { return _instance; }
        }        
        
        
        public bool Equals(Predicate<T> x, Predicate<T> y)
        {
            return x.Method.Equals(y.Method);
        }

        public int GetHashCode(Predicate<T> obj)
        {
            return obj.Method.GetHashCode();
        }
    }
}